import os.path

import albumentations as A
import cv2

from training.datasets.transform_v2 import IsotropicResizeV2

transform = A.Compose([
    IsotropicResizeV2(min_side=128),
    A.CenterCrop(height=128, width=128),
])

if __name__ == "__main__":
    root_path = 'E:\\workspace-pycharm\\deepfakes\\sifdnet-main\\plot\\img'
    image_folder = os.path.join(root_path, 'transform')
    for image_name in os.listdir(image_folder):
        image_path = os.path.join(image_folder, image_name)
        image = cv2.imread(image_path, cv2.IMREAD_COLOR)

        resized_image = transform(image=image)['image']
        resized_image_name = os.path.join(image_folder, '{}_{}.png'.format(image_name[:-4], '128'))
        cv2.imwrite(resized_image_name, resized_image)
